package com.guomao.demob;

import com.guomao.demoa.Person;

public class JavaDemo2 {

    public static void main(String[] args) {

        //1 获取Person类的字节码文件对象方式1
        Person p = new Person();
        //对象名.getClass();
        Class clazz1 = p.getClass();

        //2 类名.class属性
        Class clazz2 = Person.class;

        //3 Class.forName();
        Class clazz3 = null;
        try {
            clazz3 = Class.forName("com.guomao.demoa.Person");
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        }

        //类的字节码文件对象有且只有一个
        System.out.println(clazz1 == clazz2);
        System.out.println(clazz3 == clazz2);
    }
}
